package com.muyu.common.product.remote;

import com.muyu.common.product.domain.ProductInfo;
import com.muyu.common.product.domain.ProductSkuInfo;
import com.muyu.common.product.domain.BrandInfo;
import com.muyu.common.product.domain.CategoryInfo;
import com.muyu.common.product.domain.StockCheckReq;
import com.muyu.common.product.domain.StockCheckResp;
import com.muyu.common.core.domain.Result;
import com.muyu.common.product.remote.factory.ProductRemoteServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 商品服务远程调用接口
 *
 * @author JiaCheng
 * @version 1.0
 * @since 2025-09-21
 */
@FeignClient(name = "cloud-product", fallbackFactory = ProductRemoteServiceFallbackFactory.class)
public interface ProductRemoteService {

    /**
     * 根据商品ID获取商品信息
     */
    @GetMapping("/product/remote/info/{productId}")
    Result<ProductInfo> getProductInfo(@PathVariable("productId") Long productId);

    /**
     * 根据SKU ID获取SKU信息
     */
    @GetMapping("/product/remote/sku/{skuId}")
    Result<ProductSkuInfo> getSkuInfo(@PathVariable("skuId") Long skuId);

    /**
     * 根据品牌ID获取品牌信息
     */
    @GetMapping("/product/remote/brand/{brandId}")
    Result<BrandInfo> getBrandInfo(@PathVariable("brandId") Long brandId);

    /**
     * 根据分类ID获取分类信息
     */
    @GetMapping("/product/remote/category/{categoryId}")
    Result<CategoryInfo> getCategoryInfo(@PathVariable("categoryId") Long categoryId);

    /**
     * 批量获取商品信息
     */
    @PostMapping("/product/remote/batch")
    Result<List<ProductInfo>> getBatchProductInfo(@RequestBody List<Long> productIds);

    /**
     * 批量获取SKU信息
     */
    @PostMapping("/product/remote/sku/batch")
    Result<List<ProductSkuInfo>> getBatchSkuInfo(@RequestBody List<Long> skuIds);

    /**
     * 检查商品库存
     */
    @PostMapping("/product/remote/stock/check")
    Result<StockCheckResp> checkStock(@RequestBody StockCheckReq req);
}
